<?php
html::printPath('orgSpace.myOrganization-display-header', 'orgSpace.myOrganization-display-desc');
$msg->printMessages();
?>

<ul class="commandList">
    <li class="editLi"><?php echo html::anchor('org/myOrganization/edit', text::get('orgSpace.myOrganization-edit')) ?></li>
</ul>

<h3><?php echo text::getEscaped('organization.entity'); ?></h3>

<?php
$fb = new FormBuilder('organization', $organization);
$fb->displayOnly();
$fb->display('name')->identifyingValue();
$fb->display('country_code')->value($organization['country']['name_native'] . ' (' . $organization['country']['code'] . ')');
$fb->display('street');
$fb->display('postal_code');
$fb->display('city');
$fb->display('telephone');
$fb->display('email');
$fb->yesNoBox('emails_enabled');
$fb->comboBox('preferred_language', form::languageOptions());
$fb->display('organizer_id')->value(format::personFullName($organization['organizer']))->moreInfoPopup('/org/orgSpace/personDisplay?id=' . $organization['organizer_id']);
$fb->write();

if ($this->getSessionData()->getAuthOrgRole() == auth::$ORG_ROLE_ORGANIZER) {
    echo '<h2>' . text::getEscaped('organization.representativesOfThisOrg') . '</h2>';

    $fb = new FormBuilder('person', $organization);
    $fb->setAction('/org/myOrganization/addRepresentative');
    $fb->autocompleter('person_id', $addRepAcValues)->mustMatch()->labelKey('organization.addRepresentative');
    $fb->write();

    if ($representativeList) {
        $elb = new EntityListBuilder('person', $representativeList);
        $elb->setUuid($this->DISPLAY_REP_LIST_UUID);
        $elb->text('last_name')->linkWithValue('/org/orgSpace/personDisplay?id=', 'id')->openInPopup();
        $elb->text('first_name');
        // Organization should not get person's birth date, it's a personal data.
        $elb->date('birth_date')->yearOnly()->labelKey('person.birth_year');
        $elb->text('country_name')->labelKey('country_code');
        $elb->text('delete')->valueFunction('deleteColumnValueFunction')->labelKey('util.emptyString');
        $elb->write();
    }
}

function deleteColumnValueFunction($person, $textField) {
    return html::anchor('/org/myOrganization/removeRepresentative?person_id=' . $person['id'], 
            html::img('remove.png', array('title' => text::get('organization-removeRepresentative'))));
}